//
//  HOWebViewController.h
//  WeiDu_1_0
//
//  Created by foguo-mac-1 on 01/07/16.
//  Copyright (c) 2016 WeiDu Energy Tech. All rights reserved.
//

#import "HOWebViewController.h"
#import "HOConstants.h"
//#import "UMSocial.h"
#import "Logger.h"
#import <CoreLocation/CoreLocation.h>
#import "HOUtils.h"

@implementation HOWebViewController
@synthesize loadURL;
@synthesize navTitle;
@synthesize needShare;
@synthesize hideNavigationBar;
- (void)viewDidLoad
{
    [super viewDidLoad];
    webView = [[UIWebView alloc]initWithFrame:CGRectMake(0,
                                                         0,
                                                         self.view.frame.size.width,
                                                         self.view.frame.size.height - 64)];
    
    webView.delegate = self;

    [self.view addSubview:webView];
    
}
//- (void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response
//{
//}
//
//- (void)didFinishGetUMSocialDataResponse:(UMSocialResponseEntity *)response
//{
//}

- (void)viewWillAppear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = YES;
    self.navigationController.navigationBar.hidden = hideNavigationBar;
    [super viewWillAppear:animated];
    [self setNavigationItemTitle:navTitle];
	if(self.hideNavigationBar)
	{
		
		webView.frame = CGRectMake(0,
								   20,
								   self.view.frame.size.width,
								   self.view.frame.size.height - 44);
	}
	NSURL *URL =[NSURL URLWithString:self.loadURL];
	[webView loadRequest:[NSURLRequest requestWithURL:URL]];
}
- (IBAction)shareUrlResource:(id)sender {
    //设置URL分享内容
    //[[UMSocialData defaultData].urlResource setResourceType:UMSocialUrlResourceTypeImage url:@"http://img0.pcgames.com.cn/pcgames/1407/07/4057451_1_thumb.jpg"];
    //[UMSocialSnsService presentSnsIconSheetView:self appKey:@"53cde22c56240b55aa02368c" shareText:@"Chinajoy的萌妹子" shareImage:nil shareToSnsNames:@[UMShareToWechatSession,UMShareToQzone,UMShareToSina,UMShareToTencent,UMShareToRenren] delegate:nil];
    
    //根据url创建一个UMSocialUrlResource对象；resourceType：多媒体资源类型，图片、音乐或者视频；urlString：url字符串
//    UMSocialUrlResource *urlResource = [[UMSocialUrlResource alloc]initWithSnsResourceType:UMSocialUrlResourceTypeImage url:@"http://img0.pcgames.com.cn/pcgames/1407/07/4057451_1_thumb.jpg"];
//    //分享url资源
//    [[UMSocialDataService defaultDataService]postSNSWithTypes:@[UMShareToSina]content:@"Chinajoy的萌妹子" image:nil location:nil urlResource:urlResource presentedController:self completion:^(UMSocialResponseEntity *response) {
//        if (response.responseCode == UMSResponseCodeSuccess) {
//            NSLocalizedString(@"分享成功！", @"分享成功！");
//        }
//    }];
}

- (void)rightButtonItemDidClick
{

}

#pragma mark - -- UIWebViewDelegate
- (void)webViewDidStartLoad:(UIWebView *)webView
{
    [self showLoadingView:YES];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [self showLoadingView:NO];
}

- (void)dealloc
{
	[HOUtils removeFromSuperViewForViews:webView];
    [webView release];
    
    [super dealloc];
}
@end
